.class Lcom/qiniu/resumableio/ResumableClient$1;
.super Lcom/qiniu/auth/JSONObjectRet;
.source "ResumableClient.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/qiniu/resumableio/ResumableClient;->putblock(Lcom/qiniu/utils/InputStreamAt;Lcom/qiniu/resumableio/PutExtra;Lcom/qiniu/resumableio/PutRet;JLcom/qiniu/auth/JSONObjectRet;)[Lcom/qiniu/utils/ICancel;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field crc32:J

.field final synthetic this$0:Lcom/qiniu/resumableio/ResumableClient;

.field final synthetic val$callback:Lcom/qiniu/auth/JSONObjectRet;

.field final synthetic val$canceler:[Lcom/qiniu/utils/ICancel;

.field final synthetic val$extra:Lcom/qiniu/resumableio/PutExtra;

.field final synthetic val$input:Lcom/qiniu/utils/InputStreamAt;

.field final synthetic val$offset:J

.field final synthetic val$putRet:Lcom/qiniu/resumableio/PutRet;

.field final synthetic val$writeNeed:I

.field writing:J

.field wrote:J


# direct methods
.method constructor <init>(Lcom/qiniu/resumableio/ResumableClient;Lcom/qiniu/resumableio/PutRet;ILcom/qiniu/utils/InputStreamAt;J[Lcom/qiniu/utils/ICancel;Lcom/qiniu/resumableio/PutExtra;Lcom/qiniu/auth/JSONObjectRet;)V
    .registers 13
    .param p1, "this$0"    # Lcom/qiniu/resumableio/ResumableClient;

    .prologue
    .line 40
    iput-object p1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->this$0:Lcom/qiniu/resumableio/ResumableClient;

    iput-object p2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    iput p3, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$writeNeed:I

    iput-object p4, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$input:Lcom/qiniu/utils/InputStreamAt;

    iput-wide p5, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$offset:J

    iput-object p7, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$canceler:[Lcom/qiniu/utils/ICancel;

    iput-object p8, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$extra:Lcom/qiniu/resumableio/PutExtra;

    iput-object p9, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$callback:Lcom/qiniu/auth/JSONObjectRet;

    invoke-direct {p0}, Lcom/qiniu/auth/JSONObjectRet;-><init>()V

    .line 41
    const-wide/16 v0, 0x0

    iput-wide v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->writing:J

    return-void
.end method


# virtual methods
.method public onFailure(Ljava/lang/Exception;)V
    .registers 3
    .param p1, "ex"    # Ljava/lang/Exception;

    .prologue
    .line 85
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$callback:Lcom/qiniu/auth/JSONObjectRet;

    invoke-virtual {v0, p1}, Lcom/qiniu/auth/JSONObjectRet;->onFailure(Ljava/lang/Exception;)V

    .line 86
    return-void
.end method

.method public onInit(I)V
    .registers 4
    .param p1, "flag"    # I

    .prologue
    const/4 v0, 0x1

    .line 43
    iget-object v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    invoke-virtual {v1}, Lcom/qiniu/resumableio/PutRet;->isInvalid()Z

    move-result v1

    if-eqz v1, :cond_15

    const/4 p1, 0x0

    .line 44
    :goto_a
    if-nez p1, :cond_f

    invoke-virtual {p0}, Lcom/qiniu/resumableio/ResumableClient$1;->putInit()V

    .line 45
    :cond_f
    if-ne p1, v0, :cond_14

    invoke-virtual {p0}, Lcom/qiniu/resumableio/ResumableClient$1;->putNext()V

    .line 46
    :cond_14
    return-void

    :cond_15
    move p1, v0

    .line 43
    goto :goto_a
.end method

.method public onProcess(JJ)V
    .registers 12
    .param p1, "current"    # J
    .param p3, "total"    # J

    .prologue
    .line 79
    iput-wide p1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->writing:J

    .line 80
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$callback:Lcom/qiniu/auth/JSONObjectRet;

    iget-wide v2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->wrote:J

    iget-wide v4, p0, Lcom/qiniu/resumableio/ResumableClient$1;->writing:J

    add-long/2addr v2, v4

    iget v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$writeNeed:I

    int-to-long v4, v1

    invoke-virtual {v0, v2, v3, v4, v5}, Lcom/qiniu/auth/JSONObjectRet;->onProcess(JJ)V

    .line 81
    return-void
.end method

.method public onSuccess(Lorg/json/JSONObject;)V
    .registers 6
    .param p1, "obj"    # Lorg/json/JSONObject;

    .prologue
    .line 63
    iget-wide v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->crc32:J

    new-instance v2, Lcom/qiniu/resumableio/PutRet;

    invoke-direct {v2, p1}, Lcom/qiniu/resumableio/PutRet;-><init>(Lorg/json/JSONObject;)V

    iget-wide v2, v2, Lcom/qiniu/resumableio/PutRet;->crc32:J

    cmp-long v0, v0, v2

    if-eqz v0, :cond_12

    .line 64
    const/4 v0, -0x1

    invoke-virtual {p0, v0}, Lcom/qiniu/resumableio/ResumableClient$1;->onInit(I)V

    .line 75
    :goto_11
    return-void

    .line 67
    :cond_12
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    invoke-virtual {v0, p1}, Lcom/qiniu/resumableio/PutRet;->parse(Lorg/json/JSONObject;)Lcom/qiniu/resumableio/PutRet;

    .line 68
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$extra:Lcom/qiniu/resumableio/PutExtra;

    iget-object v0, v0, Lcom/qiniu/resumableio/PutExtra;->notify:Lcom/qiniu/resumableio/PutExtra$INotify;

    if-eqz v0, :cond_26

    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$extra:Lcom/qiniu/resumableio/PutExtra;

    iget-object v0, v0, Lcom/qiniu/resumableio/PutExtra;->notify:Lcom/qiniu/resumableio/PutExtra$INotify;

    iget-object v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$extra:Lcom/qiniu/resumableio/PutExtra;

    invoke-interface {v0, v1}, Lcom/qiniu/resumableio/PutExtra$INotify;->onSuccessUpload(Lcom/qiniu/resumableio/PutExtra;)V

    .line 69
    :cond_26
    iget-wide v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->wrote:J

    iget-wide v2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->writing:J

    add-long/2addr v0, v2

    iput-wide v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->wrote:J

    .line 70
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    iget v0, v0, Lcom/qiniu/resumableio/PutRet;->offset:I

    iget v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$writeNeed:I

    if-ne v0, v1, :cond_3b

    .line 71
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$callback:Lcom/qiniu/auth/JSONObjectRet;

    invoke-virtual {v0, p1}, Lcom/qiniu/auth/JSONObjectRet;->onSuccess(Lorg/json/JSONObject;)V

    goto :goto_11

    .line 74
    :cond_3b
    invoke-virtual {p0}, Lcom/qiniu/resumableio/ResumableClient$1;->putNext()V

    goto :goto_11
.end method

.method public putInit()V
    .registers 10

    .prologue
    .line 49
    iget v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$writeNeed:I

    iget-object v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->this$0:Lcom/qiniu/resumableio/ResumableClient;

    iget v1, v1, Lcom/qiniu/resumableio/ResumableClient;->CHUNK_SIZE:I

    invoke-static {v0, v1}, Ljava/lang/Math;->min(II)I

    move-result v5

    .line 50
    .local v5, "chunkSize":I
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$input:Lcom/qiniu/utils/InputStreamAt;

    iget-wide v2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$offset:J

    invoke-virtual {v0, v2, v3, v5}, Lcom/qiniu/utils/InputStreamAt;->getCrc32(JI)J

    move-result-wide v0

    iput-wide v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->crc32:J

    .line 51
    iget-object v7, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$canceler:[Lcom/qiniu/utils/ICancel;

    const/4 v8, 0x0

    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->this$0:Lcom/qiniu/resumableio/ResumableClient;

    iget-object v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$input:Lcom/qiniu/utils/InputStreamAt;

    iget-wide v2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$offset:J

    iget v4, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$writeNeed:I

    move-object v6, p0

    invoke-virtual/range {v0 .. v6}, Lcom/qiniu/resumableio/ResumableClient;->mkblk(Lcom/qiniu/utils/InputStreamAt;JIILcom/qiniu/auth/CallRet;)Lcom/qiniu/utils/ICancel;

    move-result-object v0

    aput-object v0, v7, v8

    .line 52
    return-void
.end method

.method public putNext()V
    .registers 13

    .prologue
    .line 55
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    iget v0, v0, Lcom/qiniu/resumableio/PutRet;->offset:I

    int-to-long v0, v0

    iput-wide v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->wrote:J

    .line 56
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$input:Lcom/qiniu/utils/InputStreamAt;

    invoke-virtual {v0}, Lcom/qiniu/utils/InputStreamAt;->length()J

    move-result-wide v0

    iget-wide v2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$offset:J

    sub-long/2addr v0, v2

    iget-object v2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    iget v2, v2, Lcom/qiniu/resumableio/PutRet;->offset:I

    int-to-long v2, v2

    sub-long/2addr v0, v2

    long-to-int v0, v0

    iget-object v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->this$0:Lcom/qiniu/resumableio/ResumableClient;

    iget v1, v1, Lcom/qiniu/resumableio/ResumableClient;->CHUNK_SIZE:I

    invoke-static {v0, v1}, Ljava/lang/Math;->min(II)I

    move-result v8

    .line 57
    .local v8, "remainLength":I
    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$input:Lcom/qiniu/utils/InputStreamAt;

    iget-wide v2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$offset:J

    iget-object v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    iget v1, v1, Lcom/qiniu/resumableio/PutRet;->offset:I

    int-to-long v4, v1

    add-long/2addr v2, v4

    invoke-virtual {v0, v2, v3, v8}, Lcom/qiniu/utils/InputStreamAt;->getCrc32(JI)J

    move-result-wide v0

    iput-wide v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->crc32:J

    .line 58
    iget-object v10, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$canceler:[Lcom/qiniu/utils/ICancel;

    const/4 v11, 0x0

    iget-object v0, p0, Lcom/qiniu/resumableio/ResumableClient$1;->this$0:Lcom/qiniu/resumableio/ResumableClient;

    iget-object v1, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    iget-object v1, v1, Lcom/qiniu/resumableio/PutRet;->host:Ljava/lang/String;

    iget-object v2, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$input:Lcom/qiniu/utils/InputStreamAt;

    iget-object v3, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    iget-object v3, v3, Lcom/qiniu/resumableio/PutRet;->ctx:Ljava/lang/String;

    iget-wide v4, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$offset:J

    iget-object v6, p0, Lcom/qiniu/resumableio/ResumableClient$1;->val$putRet:Lcom/qiniu/resumableio/PutRet;

    iget v6, v6, Lcom/qiniu/resumableio/PutRet;->offset:I

    int-to-long v6, v6

    move-object v9, p0

    invoke-virtual/range {v0 .. v9}, Lcom/qiniu/resumableio/ResumableClient;->bput(Ljava/lang/String;Lcom/qiniu/utils/InputStreamAt;Ljava/lang/String;JJILcom/qiniu/auth/CallRet;)Lcom/qiniu/utils/ICancel;

    move-result-object v0

    aput-object v0, v10, v11

    .line 59
    return-void
.end method
